#include "Client.h"

unsigned int Client::lastID = 11000;

void Client::addPreference(Type _type) {
	preferences.push_back(_type);
}

void Client::deletePreference(Type _type) {

	int index = -1;

	for (size_t i = 0; i < preferences.size(); i++) {

		if (_type == preferences[i]) {
			index = i;
		}
	}

	if (index != -1) {
		preferences.erase(preferences.begin() + index);
	}
}

void Client::showPreferences() {

	for (size_t i = 0; i < preferences.size(); i++) {
		cout << i + 1 << ") ";
		preferences[i].showType();
	}
	if(preferences.size() == 0)
	{
	cout << "You have no preferences!" << endl;
	}
	else
	{
		cout << endl;
	}

}

bool Client::preferenceExists(Type _type) {
	bool exists = false;

	for(size_t i = 0; i < preferences.size(); i++)
	{
		if(_type == preferences[i])
		{
			exists = true;
			break;
		}
	}

	return exists;
}

void Client::showClient() {
	cout << "ID: " << clientID << endl;
	cout << "Name: " << clientName << endl;
	cout << "Address: " << address << endl;
	cout << "Phone number: " << phoneNumber << endl;
	cout << "E-mail: " << email << endl;
	cout << "----------------------------------------------------------------"
			<< endl;
}

bool Client::operator==(const Client& client2) const {
	return (this->getID() == client2.getID());
}
